package com.sykj.springboot.CountDownLatch;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@SpringBootTest
@RunWith(SpringRunner.class)
public class mian {

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(4);
        CountDownLatch countDownLatch = new CountDownLatch(3);
        Worker worker1 = new Worker(countDownLatch, "张三");
        Worker worker2 = new Worker(countDownLatch, "李四");
        Worker worker3 = new Worker(countDownLatch, "王五");

        Boss boss = new Boss(countDownLatch);

        executorService.execute(boss);
        executorService.execute(worker1);
        executorService.execute(worker2);
        executorService.execute(worker3);

        executorService.shutdown();

    }

}
